package com.yuchen.ishop.service.file;


import org.apache.commons.lang.StringUtils;

import java.io.InputStream;

/**
 * @author Jack Q
 */
public class FileRequest {

    private String fileType; //不能为空 (文件类型：txt,jpg,pdf等等)
    private String folder; //不能为空
    private InputStream io;//不能为空

    public FileRequest(String fileType,String folder, InputStream io) {
        this.fileType = fileType;
        this.folder = folder;
        this.io = io;
    }

    public String getFileType() {
        return fileType;
    }

    public void setFileType(String fileType) {
        this.fileType = fileType;
    }

    public String getFolder() {
        return folder;
    }

    public void setFolder(String folder) {
        this.folder = folder;
    }

    public InputStream getIo() {
        return io;
    }

    public void setIo(InputStream io) {
        this.io = io;
    }

    public void validations(){
        if(StringUtils.isBlank(this.fileType))
            throw new FileRequestException("文件类型不能为空");
        if(StringUtils.isBlank(this.folder))
            throw new FileRequestException("文件夹不能为空");
        if(null == io )
            throw new FileRequestException("文件流不能为空");
    }
}
